/*
 * Project: BoboDesignPattern
 * 
 * File Created at 2020年1月13日
 * 
 * Copyright 2012 Greenline.com Corporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Greenline Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Greenline.com.
 */
package test.practice;

/**
 * @Type A20200113_bridge
 * @Desc
 * @author 52489
 * @date 2020年1月13日
 * @Version V1.0
 */
public class A20200113_bridge {

    abstract class AbstractMessage {

        MessageImplementor impl;

        /**
         * @param impl
         */
        public AbstractMessage(MessageImplementor impl) {
            super();
            this.impl = impl;
        }

        void send() {
            impl.send();
        };

    }

    class CommonMessage extends AbstractMessage {

        /**
         * @param impl
         */
        public CommonMessage(MessageImplementor impl) {
            super(impl);
        }

        /*
         * (non-Javadoc)
         * 
         * @see test.practice.A20200113_bridge.AbstractMessage#send()
         */
        @Override
        void send() {
            super.send();
        }

    }

    class DangerMessage extends AbstractMessage {

        /**
         * @param impl
         */
        public DangerMessage(MessageImplementor impl) {
            super(impl);
        }

        /*
         * (non-Javadoc)
         * 
         * @see test.practice.A20200113_bridge.AbstractMessage#send()
         */
        @Override
        void send() {
            System.out.println("加急消息");
            super.send();
        }

        // 扩展方法
        public Object watch(String messageId) {
            return null;
        }

    }

    interface MessageImplementor {
        void send();
    }

    class SMSMessage implements MessageImplementor {

        /*
         * (non-Javadoc)
         * 
         * @see test.practice.A20200113_bridge.MessageImplementor#send()
         */
        @Override
        public void send() {
            System.out.println("sms消息");
        }

    }

    class EmailMessage implements MessageImplementor {

        /*
         * (non-Javadoc)
         * 
         * @see test.practice.A20200113_bridge.MessageImplementor#send()
         */
        @Override
        public void send() {
            System.out.println("email消息");
        }

    }

    public static void main(String[] args) {
        AbstractMessage email = new A20200113_bridge().new CommonMessage(new A20200113_bridge().new EmailMessage());
        email.send();
        AbstractMessage dangEmail = new A20200113_bridge().new DangerMessage(new A20200113_bridge().new EmailMessage());
        dangEmail.send();

    }

}
